package ehcache;

import org.ehcache.Cache;
import org.ehcache.CacheManager;
import org.ehcache.config.builders.CacheConfigurationBuilder;
import org.ehcache.config.builders.CacheManagerBuilder;
import org.ehcache.config.builders.ResourcePoolsBuilder;

/**
 * Created by dongjigong on 2018/4/28.
 *
 * @Email osbornjonny@126.com
 * @Description
 */
public class demo1 {
    public static void main(String[] args) {
        CacheManager cacheManager = CacheManagerBuilder.newCacheManagerBuilder().withCache("demo1",
                CacheConfigurationBuilder.newCacheConfigurationBuilder(Long.class, String.class, ResourcePoolsBuilder.heap(10))).build();
        cacheManager.init();

        Cache<Long, String> preConfigured = cacheManager.getCache("demo1", Long.class, String.class);

        Cache<Long, String> mycache = cacheManager.createCache("mycache",
                CacheConfigurationBuilder.newCacheConfigurationBuilder(Long.class, String.class, ResourcePoolsBuilder.heap(10)));
        mycache.put(1L, "da one!");
        cacheManager.removeCache("demo1");
        cacheManager.removeCache("demo1");
        cacheManager.removeCache("demo3");
        cacheManager.close();
    }
}
